﻿using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;

namespace FutureApp.Shop.Dto
{
    /// <summary>
    /// 更新商品输入参数DTO
    /// </summary>
    [AutoMapTo(typeof(GoodsItem))]
    public class UpdateGoodsInput
    {
        /// <summary>
        /// Id
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// 商品名称
        /// </summary>
        [Required(ErrorMessage = "商品名称不能为空")]
        [StringLength(GoodsItem.MaxNameLength)]
        public string Name { get; set; }

        /// <summary>
        /// 商品品牌
        /// </summary>
        [Required]
        public Guid BrandId { get; set; }

        /// <summary>
        /// 商品分类
        /// </summary>
        [Required]
        public Guid CategoryId { get; set; }

        /// <summary>
        /// 商品SKU列表
        /// </summary>
        public ICollection<UpdateGoodsSKUInput> SKUs { get; set; }

        /// <summary>
        /// 商品SKU列表
        /// </summary>
        public ICollection<UpdateGoodsSKUInput> GoodsList
        {
            get
            {
                foreach (var item in this.SKUs)
                {
                    item.ItemId = this.Id;
                }
                return this.SKUs;
            }
        }
    }
}